#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
int main()
{
    int a[1000] = { 0 };
    int b[1000] = { 0 };
    int c[30000] = { 0 };
    int n = 0;
    int m = 0;
    scanf("%d%d", &n, &m);
    int i = 0;
    int j = 0;
    int k = 0;
    for (i = 0; i < n; i++)
    {
        scanf("%d", &a[i]);
    }
    for (j = 0; j < m; j++)
    {
        scanf("%d", &b[j]);
    }
    i = 0;
    j = 0;
    while (i < n && j < m)
    {
        if (a[i] < b[j])
        {
            c[k++] = a[i];
            i++;
        }
        else
        {
            c[k++] = b[j];
            j++;
        }
    }
    while (j < m)
    {
        c[k++] = b[j++];
    }
    while (i < n)
    {
        c[k++] = a[i++];
    }
    for (i = 0; i < m + n; i++)
    {
        printf("%d ", c[i]);
    }
}